/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package modele;

import java.util.Collection;


public class Pays {
    
    private Collection<Dep> LesDep;
    private Collection<Spe> LesSpes;
    

    public Pays() {
        this.LesDep=DAO.getLesDeps();
        this.LesSpes=DAO.getLesSpes();
        this.assocMedecins(DAO.getLesMeds());
    }

    
    public Collection<Dep> getLesDep() {
        return LesDep;
    }
    
    public Collection<Spe> getLesSpes() {
        return LesSpes;
    }
    
    private void assocMedecins(Collection<Med> lesMeds) {
        for(Med unMed: lesMeds) {
            getLeDep(unMed.getDep()).addUnMed(unMed);
            Spe uneSpe = getLaSpe(unMed.getSpe());
            if (uneSpe != null){
                uneSpe.addUnMed(unMed);
            }
        }
    }
    
    public Dep getLeDep(String numDep){       
        for(Dep unDep : LesDep) {
            if (unDep.getNum().equals(numDep)){
                return unDep;
            }
        }
        return null;           
    }

    public Spe getLaSpe(String nomSpe) {
        for(Spe uneSpe : LesSpes) {
            if (uneSpe.getNomSpe().equals(nomSpe)){
                return uneSpe;
            }
        }
        return null;
    }
    
    
}